JavaScript
A5.u.templateparse Method
Syntax
A5.u.template.parse(template)
Arguments
- templatestring
The template string to parse.
Returns
- parsedTemplateobject
The parsed template.
Description
Parse a template into a low level template object.
Discussion
If you are going to expand a template multiple times, it is best to parse the template and do the expand with the parsed template. This will allow the template expand function to not have to parse the template each time it expands.
Example
var temp = 'Hello {firstname} {lastname}!'; var pTemp = A5.u.template.parse(temp); var data = {firstname: 'Bob', lastname: 'Thomas'}; var welcomeStr = A5.u.template.expand(data,{template: temp}); // welcomeStr = 'Hello Bob Thomas!'